package com.ssyan.appointment.common.exception;

import com.ssyan.appointment.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHanlder {

    //系统异常处理
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    //自定义预约挂号异常
    @ExceptionHandler(AppointmentException.class)
    @ResponseBody
    public Result error(AppointmentException e){
        e.printStackTrace();
        return Result.fail();
    }
}
